// import store from '@/store/index.js'
import {
	imgageUrl
} from '@/common/public.js'
export default {
	data() {
		return {
			// 默认的全局分享内容
			share: {
				title: '温邻圈',
				path: '/pages/index/index', // 全局分享的路径，比如 首页
				imageUrl: '/static/fenxianglogo.png', // 全局分享的图片(可本地可网络)
			}
		}
	},
	// 定义全局分享
	// 1.发送给朋友
	onShareAppMessage(res) {
		let pages = getCurrentPages();
		let currentPage = pages[pages.length - 1]
		let url = currentPage.$page.fullPath
		let image = this.share.imageUrl
		let title = this.share.title
		if (currentPage.$vm.fx) {
			if (currentPage.$vm.fx.image) {
				image = imgageUrl(currentPage.$vm.fx.image)
			}
			if (currentPage.$vm.fx.title) {
				title = currentPage.$vm.fx.title
			}
		}

		return {
			title: title,
			path: url,
			imageUrl: image,
		}
	},
	//2.分享到朋友圈
	onShareTimeline(res) {
		// console.log("分享到朋友圈", "userId=" + store.state.userInfo.id)
		let pages = getCurrentPages();
		let currentPage = pages[pages.length - 1]
		let url = currentPage.$page.fullPath
		let image = this.share.imageUrl
		let title = this.share.title
		if (currentPage.$vm.fx) {
			if (currentPage.$vm.fx.image) {
				image = imgageUrl(currentPage.$vm.fx.image)
			}
			if (currentPage.$vm.fx.title) {
				title = currentPage.$vm.fx.title
			}
		}

		return {
			title: title,
			path: url,
			imageUrl: image,
		}
	},
}